/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #ff9a8b, #fecfef, #fecfef, #a8e6cf);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Main Game Container - Responsive Height */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Adjust height when not in iframe */
@media (min-height: 500px) {
    .game-container {
        height: 90vh;
    }
}

/* Progress Section */
.progress-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: white;
    font-size: 14px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    margin-right: 16px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #56ab2f, #a8e6cf);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.score-display {
    display: flex;
    gap: 16px;
    font-weight: bold;
}

/* Main Game Area */
.main-game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Map Hub Styles */
.map-hub {
    width: 100%;
    height: 100%;
    display: none;
    padding: 16px;
}

.map-hub.active {
    display: block;
}

.hawker-map {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr auto;
    gap: 12px;
    position: relative;
}

/* Stall Styles */
.stall {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stall:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stall.completed {
    background: linear-gradient(145deg, #a8e6cf, #88d8a3);
}

.stall-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.stall-name {
    font-size: 12px;
    font-weight: bold;
    line-height: 1.2;
}

.stall-name small {
    font-size: 10px;
    opacity: 0.7;
    font-weight: normal;
}

.completion-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.stall.completed .completion-badge {
    display: flex;
}

/* Reflection Corner */
.reflection-corner {
    grid-column: 1 / -1;
    background: linear-gradient(145deg, #ffd89b, #19547b);
    color: white;
    border-radius: 16px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.reflection-corner.locked {
    background: linear-gradient(145deg, #cccccc, #999999);
    cursor: not-allowed;
}

.reflection-corner:not(.locked):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.corner-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.corner-name {
    font-size: 12px;
    font-weight: bold;
}

.lock-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 16px;
}

.reflection-corner:not(.locked) .lock-icon {
    display: none;
}

/* Stall Screen Styles */
.stall-screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: white;
}

.stall-screen.active {
    display: flex;
}

.stall-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: white;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.stall-header h2 {
    margin-left: 12px;
    font-size: 16px;
}

/* Dialogue Section */
.dialogue-section {
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #f8f9fa;
}

.character-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ff9a8b, #fecfef);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.dialogue-box {
    flex: 1;
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.chinese-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
}

.tooltip {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Choices Section */
.choices-section {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.choice-btn {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 13px;
    line-height: 1.4;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.choice-btn:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.choice-btn.correct {
    background: linear-gradient(145deg, #a8e6cf, #88d8a3);
    border-color: #4CAF50;
}

.choice-btn.incorrect {
    background: linear-gradient(145deg, #ffcccb, #ff9999);
    border-color: #f44336;
}

/* Feedback Section */
.feedback-section {
    padding: 16px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    display: none;
}

.feedback-section.active {
    display: block;
}

.feedback-box {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.feedback-box p {
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

/* Quiz Screen Styles */
.quiz-screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: white;
}

.quiz-screen.active {
    display: flex;
}

.quiz-header {
    padding: 16px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quiz-header h2 {
    font-size: 16px;
}

.quiz-progress {
    font-size: 14px;
    font-weight: bold;
}

.question-section {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.question-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.question-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 13px;
    line-height: 1.4;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.option-btn:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quiz-navigation {
    padding: 16px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.nav-btn {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-height: 44px;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.nav-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Results Screen */
.results-screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: white;
    overflow-y: auto;
}

.results-screen.active {
    display: flex;
}

.results-content {
    flex: 1;
    padding: 16px;
    text-align: center;
}

.results-content h2 {
    color: #667eea;
    margin-bottom: 16px;
    font-size: 18px;
}

.final-score {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.score-item:last-child {
    margin-bottom: 0;
}

.reflection-input {
    margin-bottom: 16px;
    text-align: left;
}

.reflection-input label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

.reflection-input textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    resize: vertical;
    font-family: inherit;
}

.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.action-btn {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-height: 44px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Control Panel */
.control-panel {
    position: absolute;
    top: 50px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Timer Display */
.timer-display {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    display: none;
    z-index: 101;
}

.timer-display.active {
    display: block;
}

/* Global Tooltip */
.global-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    word-wrap: break-word;
}

.global-tooltip.show {
    opacity: 1;
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
    .progress-section {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .score-display {
        gap: 12px;
    }
    
    .hawker-map {
        gap: 8px;
        padding: 12px;
    }
    
    .stall {
        padding: 12px;
        min-height: 70px;
    }
    
    .stall-icon {
        font-size: 20px;
    }
    
    .stall-name {
        font-size: 11px;
    }
    
    .reflection-corner {
        min-height: 50px;
        padding: 8px;
    }
    
    .corner-icon {
        font-size: 18px;
    }
    
    .corner-name {
        font-size: 11px;
    }
    
    .dialogue-section {
        padding: 12px;
        gap: 8px;
    }
    
    .character-avatar {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .chinese-text {
        font-size: 13px;
    }
    
    .choice-btn, .option-btn {
        font-size: 12px;
        padding: 10px 12px;
        min-height: 40px;
    }
    
    .control-panel {
        right: 4px;
        top: 45px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}